package org.tabularium.text.html;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;


/**
 * Represents a generic attribute for a Html tag (e.g, style, class). The
 * following attributes are also stored in different fields of hypertext units.
 * 
 * <pre>
 * TITLE attribute of LINK tags is stored as text; 
 * ALT attribute of IMG tags is stored as text;
 * SRC attribute of IMG tags as tag's URL.
 * </pre>
 * 
 * Attributes stored as text can be retrieved by calling
 * {@link HypertextUnit#getText()}. A complete list of attributes can be found
 * here: <a href="http://www.w3.org/TR/html401/index/attributes.html">HTML 4
 * Attributes</a>.
 */
public class HypertextUnitAttribute implements Cloneable, Serializable {
	String name;
	String value;

	/**
	 * Returns the name of the key.
	 * 
	 * @return A non-null string.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the String value of the attribute.
	 * 
	 * @return A string or null if value is not present.
	 */
	public String getValue() {
		return value;
	}

	@Override
	public String toString() {
		return name + ":" + value;
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		return super.clone();
	}

	private void writeObject(java.io.ObjectOutputStream out)
			throws IOException {
		out.writeObject(name);
		out.writeObject(value);

	}

	private void readObject(java.io.ObjectInputStream in) throws IOException,
			ClassNotFoundException {
		name = (String)in.readObject();
		value = (String)in.readObject();
	}

}
